package com.ant.rxjava.webtest.ui.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;

/**
 * Created by Ant on 2018/2/8  9:52
 * <p>
 * <p>
 *
 * @version 1.0.0
 * @auther Ant
 */

public abstract class BaseActivity extends AppCompatActivity implements IBaseActivity {


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        myCreate();
    }

    protected void myCreate() {
        initLayout();
        initView();
        initListener();
        initData();
    }

    @Override
    public void getData() {
    }


    public void initToolBar() {
        ActionBar acBar = getSupportActionBar();
        if (acBar == null)
            return;
        //acBar.setDefaultDisplayHomeAsUpEnabled(true);
        acBar.setDisplayHomeAsUpEnabled(true);

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
